<?php

namespace App\Model;


use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;

class SupportType extends BaseModel
{
    protected $connection = 'mysql';
    protected $table = 'support_type';

    public function getList()
    {
        return DB::table($this->table)->get();

    }

    public function createSupportType(Request $request)
    {
        $data['support_name'] = $request->input('support_name');
        $data['support_desc'] = $request->input('support_desc');
        $data['type'] = $request->input('type') ?? 1;
        if ($request->input('id')) {
            $where['id'] = $request->input('id');
            return DB::table($this->table)->where($where)->update($data);
        } else {
            return DB::table($this->table)->insertGetId($data);
        }
    }

    public function getSupportTypeFirst($id)
    {
        return DB::table($this->table)->where(['id'=>$id])->first();
    }

    public function del($id)
    {
        return DB::table($this->table)->where(['id' => $id])->delete();
    }


}
